package com.zhdl.network.comm.conf;

import com.project.command.faq.analysis.ComAnalysisStrategyContext;
import com.project.command.faq.event.client.MessageInData;
import com.project.command.faq.event.distribution.DistributionBSSource;
import com.project.command.faq.queues.data.ControlInstructionPerformData;
import com.project.command.faq.service.ReceiveServiceImpl;
import com.zhdl.network.comm.after.NoneAnalysisAfterDefaultService;
import com.zhdl.network.comm.before.NoneAnalysisBeforeDefaultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import static com.project.common.constant.Dic.HAND_AFTER_DEFAULT_SERVICE;
import static com.project.common.constant.Dic.HAND_BEFORE_DEFAULT_SERVICE;
import static com.zhdl.network.comm.analysis.CommDemoAnalysis.COMM_DEMON;

/**
 * 自定义默认非 FAQ 后置策略配置
 *
 * @Author: zhangyy
 * @Email: zhang10092009@hotmail.com
 * @Date: 2023/12/13 9:57:37
 * @Version: v1.0
 * @Modified:
 * @Description:
 */
@Slf4j
@Service
public class CommDemoReceiveServiceImpl extends ReceiveServiceImpl {

    public CommDemoReceiveServiceImpl(ComAnalysisStrategyContext comAnalysis, DistributionBSSource distributionBSSource) {
        super(comAnalysis, distributionBSSource);
    }

    @Override
    public boolean skipFaqReceive(String protocols) {
        // 要不走 faq 协议
        return COMM_DEMON.equals(protocols);
    }

    @Override
    protected void setNowQueueData(MessageInData message, ControlInstructionPerformData nowQueueData) {
        nowQueueData.setPortKey(message.getPort());
        nowQueueData.setDataBit(1);
        nowQueueData.setProtocols(message.getProtocols());
        nowQueueData.setExpectResults("00");
        nowQueueData.setChain("");
        // 绑定的前后置处理策略
        nowQueueData.setAfterInstructionName(NoneAnalysisAfterDefaultService.NONE_ANALYSIS_AFTER);
        nowQueueData.setBeforeInstructionName(NoneAnalysisBeforeDefaultService.NONE_ANALYSIS_BEFORE);
    }
}
